
const PostsModel = require('../model/PostsModel.js')
const moment = require('moment')

// post方法
exports.getAllpost = function (req, res) {
    let data = req.query
    PostsModel.getAllpost(data, (err, resluts) => {
        if (err) {
            res.json({ code: 200, msg: '查询数据错误' })
        } else {
            // 把日期表漂亮,下载引入moment,遍历比日期改了
            for (let i = 0; i < resluts.length; i++) {
                resluts[i].created = moment(resluts[i].created).format('YYYY--MM-DD HH:mm-ss')
            }
            res.json({ code: 200, msg: '查询数据成功', data: resluts })
        }

    })
}
